package com.itwn.portal.config;

import org.springframework.amqp.core.Queue;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {

    /**
     * 创建队列：如果队列不存在则创建；队列存在，不创建、不做其他操作。
     * @return
     */
    @Bean
    public Queue emailQueue() {
        return new Queue("email.queue",true);
    }

    /**
     * 消息序列化配置
     */
    @Bean
    public MessageConverter messageConverter(){
        return new Jackson2JsonMessageConverter();
    }

}
